package builder

import "fmt"

type Cal struct {
	a int
	b int
	v int
	t string
}

func (c *Cal) SetA(a int) {
	c.a = a
}

func (c *Cal) SetB(b int) {
	c.b = b
}

func (c *Cal) SetT(t string) {
	c.t = t
}

func (c *Cal) Compute() {
	switch c.t {
	case "+":
		c.v = c.a + c.b
	case "-":
		c.v = c.a - c.b
	case "*":
		c.v = c.a * c.b
	case "/":
		c.v = c.a / c.b
	}
}

func (c *Cal) String() string {
	return fmt.Sprintf("%d %s %d = %d\n", c.a, c.t, c.b, c.v)
}
